RE: Is anyone subscribed to this list besides me?

by Kynn Bartlett <kynn-hwg(at)idyllmtn.com>

 Date:  Fri, 9 Mar 2001 17:07:04 +0100
 To:  "Mike Furmedge" <mike(at)clockworx.co.uk>,
"Aaron Choate" <achoate(at)achoate.com>,
<hwg-xml(at)hwg.org>
 References:  co
  todo: View Thread, Original
At 11:25 AM +0000 3/9/01, Mike Furmedge wrote:
>	My god....life!
>
>	Yeah, I subscribed to this list a while ago to see if I could 
>see how to
>get started using XML with HTML but I don't think I've ever seen a post on
>it.

Yeah, to the best of my knowledge this is the smallest of the HWG's
discussion lists.

What do you want to know about? :)

XML is just a set of rules for defining markup languages.  You can
define your own XML languages or you can use someone else's.  Here's
an example of an XML language i just made up:

<?xml version="1.0"?>
<dogml>
   <dog>
     <name>Kim</name>
     <breed>Tibetan Mastiff</breed>
     <dob>25 December 1989</dob>
     <color location="body">black</color>
     <color location="toes">white</color>
   </dog>
</dogml>

It's certain things about my dog, described in an XML language.
Whoop de doo, huh?

The cool thing tho is that because I've followed the rules for XML,
I can use this with other programs and applications which work with
XML.  E.g. I can use this with an XML editor program.  I don't
have to build new tools to use my markup language.

I can also use XSLT (Extensible Stylesheet Language Transformations)
to change from one XML language to another.  For example, from
DogML to XHTML.

What's XHTML?  In the most basic sense (XHTML 1.0), it's just old
familiar HTML 4 written according to the rules of XML.

XSLT looks something like this:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
   xmlns="http://www.w3.org/1999/xhtml">

   <xsl:strip-space elements="*"/>
   <xsl:output method="html" indent="yes"/>

   <xsl:template match="/">
     <h tml>
       <head>
         <title><xsl:value-of select="/dogml/dog/name"/></title>
       </head>
       <body>
         <xsl:apply-templates/>
       </body>
     </h tml>
   </xsl:template>

   <xsl:template match="dog">
     <h1><xsl:value-of select="name"/></h1>
     <p>
       <b>Breed:</b>
       <xsl:value-of select="breed"/>
       <br/>
       <b>Date of Birth:</b>
       <xsl:value-of select="dob"/>
     </p>
     <h2>Colors:</h2>
     <ul>
       <xsl:apply-templates select="color"/>
     </ul>
   </xsl:template>

   <xsl:template match="color">
     <li><xsl:value-of select="."/>
         <xsl:text> (</xsl:text>
         <xsl:value-of select="@location"/>
         <xsl:text>)</xsl:text>
     </li>
   </xsl:template>
</xsl:stylesheet>

NOTE:  In the example above I have "broken" the html tag because it
confuses some email clients if I leave that in.

If you apply the XSLT stylesheet above to the XML (DogML) file, you
will get something like this:

<h tml xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
       <title>Kim</title>
    </head>
    <body>
       <h1>Kim</h1>
       <p><b>Breed:</b>Tibetan Mastiff<br><b>Date of Birth:</b>25 December 1989
       </p>
       <h2>Colors:</h2>
       <ul>
          <li>black (body)</li>
          <li>white (toes)</li>
       </ul>
    </body>
</h tml>

Of course, this is a trivial (read: "stupid") example, but maybe you will
find it of use.

--Kynn

-- 
Kynn Bartlett <kynn(at)idyllmtn.com>
http://www.kynn.com/

HWG hwg-xml mailing list archives, maintained by Webmasters